import { error } from '@sveltejs/kit'; import { readFileSync, existsSync } from 'fs'; import { join } from 'path'; import type { PageServerLoad } from './$types'; // Simple markdown to HTML converter (we'll enhance this later) function markdownToHtml(markdown: string): string { let html = markdown; // Headers html = html.replace(/^# (.*$)/gm, '

$1

'); html = html.replace(/^## (.*$)/gm, '

$1

'); html = html.replace(/^### (.*$)/gm, '

$1

'); html = html.replace(/^#### (.*$)/gm, '

$1

'); // Bold and italic html = html.replace(/\*\*(.*?)\*\*/g, '$1'); html = html.replace(/\*(.*?)\*/g, '$1'); // Code blocks html = html.replace(/```(\w+)?\n([\s\S]*?)```/g, '
$2
'); html = html.replace(/`(.*?)`/g, '$1'); // Links html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1'); // Lists html = html.replace(/^[\s]*\*[\s]+(.*$)/gm, '
  • $1
  • '); html = html.replace(/^[\s]*\-[\s]+(.*$)/gm, '
  • $1
  • '); html = html.replace(/(
  • .*<\/li>)/gs, ''); // Paragraphs html = html.replace(/\n\n/g, '

    '); html = '

    ' + html + '

    '; // Clean up empty paragraphs and fix nested lists html = html.replace(/

    <\/p>/g, ''); html = html.replace(/

    ()/g, '$1'); html = html.replace(/(<\/h[1-6]>)<\/p>/g, '$1'); html = html.replace(/

    (